*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*	This is the Master program for cleaning the NYC MS raw data.
*	----------------------------------------------------------------------------

	clear all
	set more off
	set maxvar 	32767
	set matsize 11000

*	paths

	global rawdata 				"${data_raw_NYCms}"
	global cleandata 			"${data_clean_NYCms}"

* settings

	local bw 					"ccftcovs_bwall"

* switches

	local convert 				1	//transform txts into dta files and eliminate
	local enrollment 	 		1 	//clean the enrollment file
	local baselines				1 	//clean baseline scores
	local applications			1	//Combine application, demographic data
	local tests					1 	//clean outcome tests
	local match 				1 	//clean match file
	local pscores 				1	//calculate pscores
		local mdrd2 		1		//mdrd2 pscores (bw and rv options in pscores.do)
		local mdrd1 		1		//mdrd1 pscores
		local prgs 			1		//save program-level pscores
		local schs 			1		//save school-level pscores
	local compile				1	//compile cleaned raw data

*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* do

	// txt to dta
	if `convert'  				do "${code_clean_NYCms}c_convert"

	// clean enrollment
	if `enrollment' 			do "${code_clean_NYCms}c_enrollment"

	// clean Baseline Scores
	if `baselines' 				do "${code_clean_NYCms}c_baselines"

	// clean application data, merge with demo data
	if `applications'			do "${code_clean_NYCms}c_applications"

	// cleaning outcome test scores
	if `tests' 					do "${code_clean_NYCms}c_tests" `regents' `sat' `psat'

	// clean match file
	if `match' 					do "${code_clean_NYCms}c_match"

	// create pscores
	if `pscores' 				do "${code_clean_NYCms}c_pscores" `mdrd2' `mdrd1' `prgs' `schs' `bw'

	// compile the basefile
	if `compile' 				do "${code_clean_NYCms}c_compile" `bw'
